﻿using System;
using System.Globalization;
using System.Windows.Data;
using static System.Windows.Application;

namespace Red.Controls.Converters
{
    /// <summary>
    /// Attempts to convert a string into a canvas by searching the application resource dictionary
    /// </summary>
    public sealed class KeyToCanvasConverter : IValueConverter
    {
        #region IValueConverter

        public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
        {
            string key = (string)value;

            return Current.TryFindResource( key );
        }

        public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
        {
            throw new NotImplementedException();
        }

        #endregion IValueConverter
    }
}
